<?php
class Sosweb_Util_Image_Processing
{
	public static function scale($photo, $maxWidth, $maxHeight)
	{
		$image_size = getimagesize($photo);
		
		$scale_factor_w = ($maxWidth-10)/$image_size[0];
		$scale_factor_h = ($maxHeight-10)/$image_size[1];
		
		if($scale_factor_w < $scale_factor_h)
		{
			$scale_factor = $scale_factor_w;
		}
		else
		{
			$scale_factor = $scale_factor_h;		
		}
		
		return array('width' => round($image_size[0]*$scale_factor), 'height' => round($image_size[1]*$scale_factor));			
	}
}